package Circuit;

import TopK.DerivationTree;

import java.util.Vector;

import Basics.*;

public class CircuitNode extends Atom 
{
	CircuitNode parent;
	
	String type;
	
	Rule ruleUsed;
	
	int level;
	
	boolean isTopKUpdated;
	
	Vector<CircuitNode> children  = new Vector<CircuitNode>();
	
	Vector<DerivationTree> Trees = new Vector<DerivationTree>();
	
	public CircuitNode () {}
	
	
	
	public CircuitNode (Atom atom, String itype) 
	{
		super(atom);
		this.type = itype;
		this.parent = new CircuitNode();
	}
	
	
	
	public CircuitNode (Atom iself, String itype, CircuitNode iparent) 
	{
		super(iself);
		this.type = itype;
		this.parent = iparent;
	}



	public CircuitNode getParent() {
		return parent;
	}



	public void setParent(CircuitNode parent) {
		this.parent = parent;
	}



	public Vector<DerivationTree> getTrees() {
		return Trees;
	}



	public void setTrees(Vector<DerivationTree> trees) {
		Trees = trees;
	}



	public String getType() {
		return type;
	}



	public void setType(String type) {
		this.type = type;
	}



	public Rule getRuleUsed() {
		return ruleUsed;
	}



	public void setRuleUsed(Rule ruleUsed) {
		this.ruleUsed = ruleUsed;
	}
	

	public int getLevel() {
		return level;
	}



	public void setLevel(int level) {
		this.level = level;
	}
	

	public Vector<CircuitNode> getChildren() {
		return children;
	}



	public void setChildren(Vector<CircuitNode> children) {
		this.children = children;
	}
	

	public boolean isTopKUpdated() {
		return isTopKUpdated;
	}



	public void setTopKUpdated(boolean isTopKUpdated) {
		this.isTopKUpdated = isTopKUpdated;
	}



	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((Trees == null) ? 0 : Trees.hashCode());
		result = prime * result + level;
		result = prime * result + ((parent == null) ? 0 : parent.hashCode());
		result = prime * result
				+ ((ruleUsed == null) ? 0 : ruleUsed.hashCode());
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}



	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		CircuitNode other = (CircuitNode) obj;
		if (Trees == null) {
			if (other.Trees != null)
				return false;
		} else if (!Trees.equals(other.Trees))
			return false;
		if (level != other.level)
			return false;
		if (parent == null) {
			if (other.parent != null)
				return false;
		} else if (!parent.equals(other.parent))
			return false;
		if (ruleUsed == null) {
			if (other.ruleUsed != null)
				return false;
		} else if (!ruleUsed.equals(other.ruleUsed))
			return false;
		if (type == null) {
			if (other.type != null)
				return false;
		} else if (!type.equals(other.type))
			return false;
		return true;
	}




	
	
	
	
}
